<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>双向绑定</title>
</head>
<body>
    <div id="app">
        <!-- 表单的值切换,变量的值也切换了 -->
        <input type="text" v-model="message" @keyup.enter="fun">
        <span>{{message}}</span>

        <!-- 变量的值切换,表单的值也切换了 -->
        <input type="button" value="切换message的值" @click="solve">
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

    <script>
        var vue = new Vue({
            el:"#app",
            data:{
                message:"ABC"
            },
            methods:{
                
                fun:function(){
                    alert(this.message)
                } ,
                solve:function(){
                    this.message="new"
                }
            }
        })
    </script>
</body>
</html>